from typing import Dict


def generate_plan(score: float, anomaly_prob: float) -> Dict:
    """Rule-based placeholder for DQN policy output.
    Maps evaluation to a daily plan with reps, sets, and exercises.
    """
    if score < 40 or anomaly_prob > 0.6:
        level = 'beginner'
        reps = 8
        sets = 2
        rest = 90
    elif score < 70 or anomaly_prob > 0.4:
        level = 'intermediate'
        reps = 10
        sets = 3
        rest = 60
    else:
        level = 'advanced'
        reps = 12
        sets = 3
        rest = 45

    exercises = [
        {'name': '肩关节外展', 'duration_min': 5, 'cue': '缓慢均匀'},
        {'name': '肘关节屈伸', 'duration_min': 5, 'cue': '避免耸肩'},
        {'name': '前臂旋前/旋后', 'duration_min': 5, 'cue': '保持中立位'},
        {'name': '抓握训练（软球）', 'duration_min': 5, 'cue': '均匀用力'},
    ]

    return {
        'level': level,
        'reps': reps,
        'sets': sets,
        'rest_seconds': rest,
        'exercises': exercises,
        'notes': '如有疼痛>4分或疲劳明显，减少强度并休息。'
    }